/*
 * Copyright (C) 20015 MaiNaEr All rights reserved
 */
package com.mainaer.wjokhttp.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.mainaer.wjokhttp.R;
import com.mainaer.wjokhttp.model.MovieListResponse;
import com.mainaer.wjokhttp.ui.view.GlideImageView;

/**
 * 电影 list 适配器
 *
 * @author wangjian
 * @date 2016/3/28.
 */
public class MovieListAdapter extends HolderAdapter<MovieListResponse.SearchBean> {

    public MovieListAdapter(Context context) {
        super(context);
    }

    @Override
    protected ViewHolder<MovieListResponse.SearchBean> createHolder(MovieListResponse.SearchBean obj) {
        return new MovieHolder();
    }



    private class MovieHolder extends ViewHolder<MovieListResponse.SearchBean>{

         private GlideImageView mPosterIv;
         private TextView mTitleTv;
         private TextView mTypeTv;
         private TextView mYearTv;

        @Override
        public View init(MovieListResponse.SearchBean data, ViewGroup viewGroup, Context context) {
           View view = View.inflate(context, R.layout.movie_list_item, null);
            mPosterIv = view.findViewById(R.id.iv_poster);
            mTitleTv = view.findViewById(R.id.tv_title);
            mTypeTv = view.findViewById(R.id.tv_type);
            mYearTv = view.findViewById(R.id.tv_year);
            return view;
        }

        @Override
        public void bind(MovieListResponse.SearchBean data, int position, Context context) {
            mPosterIv.setImageURL(data.Poster);
            mTitleTv.setText(data.Title);
            mTypeTv.setText(data.Type);
            mYearTv.setText(data.Year);
        }
    }

}
